<script>
export default {
  name: "userAuthority",
  data() {
    return {
      userData: localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")) : {},
      Authorities: localStorage.getItem("authorities") ? JSON.parse(localStorage.getItem("authorities")) : {},
      tableData: [],
      userID: '',
      username: "",
      authorityID: '',
      authorityCode: '',
      authorityName: "",
      userAuthority: {},
      dialogFormVisible: false,
      userIDVisible: false,
      deleted_id: 0,
    }
  },
  created(){
    this.firstLoad()
  },
  methods: {
    firstLoad() {
      this.request.get("http://localhost:9090/user/allAuthority").then(res => {
        console.log(res);
        this.tableData = res.data;
        this.total = res.total;
      })
    },
    load() {
      this.request.get("http://localhost:9090/user/findAuthority",  {
        params: {
          userID: this.userID
        }
      }).then(res => {
        console.log(res);
        this.tableData = res.data;
        this.total = res.total;
      })
    },
    reset(){
      this.userID = '';
      this.username = "";
      this.authorityID = '';
      this.authorityCode = '';
      this.authorityName = "";
      this.firstLoad();
    }
  }
}
</script>

<template>
  <div>
    <div style="margin: 10px 0">
      <el-input style="width: 150px" placeholder="请输入用户ID" suffix-icon="el-icon-search" v-model="userID" :disabled="!this.Authorities.Authority12"></el-input>
      <el-button class="ml-5" type="primary" @click="load" :disabled="!this.Authorities.Authority12">搜索</el-button>
      <el-button type="warning" @click="reset" :disabled="!this.Authorities.Authority12">重置</el-button>
    </div>
    <el-table :data="tableData" border stripe header-cell-class-name="headerBg">
      <el-table-column prop="userID" label="userID" width="130"></el-table-column>
      <el-table-column prop="username" label="用户名" width="160"></el-table-column>
      <el-table-column prop="authorityID" label="authorityID" width="160"></el-table-column>
      <el-table-column prop="authorityCode" label="权限编码" width="160"></el-table-column>
      <el-table-column prop="authorityName" label="权限名" width="160"></el-table-column>
    </el-table>
  </div>
</template>

<style scoped>

</style>